package com.repair.servlet.serchmodule;

import java.io.IOException;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.hibernate.envers.tools.Tools;

import com.repair.domain.Module;
import com.repair.service.Module.ModuleService;
import com.repair.utils.Constants;

public class SerchmoduleServlet extends HttpServlet {
	/**
	 * 
	 */
	private static final long serialVersionUID = -2654137191968619308L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {

		String key = req.getParameter("key");
		key = com.repair.utils.Tools.changeCode(key, req.getMethod(),
				Constants.code_GBK);

		ModuleService ms = new ModuleService();

		List<Module> module = ms.serchmodule(key);
		req.setAttribute("module", module);
		req.setAttribute("key", key);
		RequestDispatcher rd = req.getRequestDispatcher("jsp/mokuaiguanli.jsp");
		rd.forward(req, resp);
	}
}
